package com.erainm.sort;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * Created by erainm on 2021/08/14/5:45 下午.
 *
 * @Description: mapper，按照预期格式输出
 */
public class SortMapper extends Mapper<Object, Text, IntWritable,IntWritable> {
    IntWritable mapperValue = new IntWritable();//存放key
    @Override
    protected void map(Object key, Text value, Context context) throws IOException, InterruptedException {
        String line = value.toString();
        mapperValue.set(Integer.parseInt(line));
        context.write(mapperValue,new IntWritable(1));
    }
}